﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 逻辑
{
    public class 帅:QiZi
    {
        public 帅(QiPan q,Button[,] b,int p):base("帅",0,4,q,p,b)
        {
        }
        public override void CanPut()
        {
            canPut.Clear();
            if(x+1<=2&& (buttons[x+1,y].Tag==null|| (buttons[x + 1, y].Tag as QiZi).Player!=this.Player))
            {
                int z = Game.ChangeDirection(this.Player, x + 1);
                canPut.Add(z * 10 + y);
            }
            if ((x -1 <= 2&&x-1>=0 )&& (buttons[x - 1, y].Tag == null || (buttons[x - 1, y].Tag as QiZi).Player != this.Player))
            {
                int z = Game.ChangeDirection(this.Player, x - 1);
                canPut.Add(z * 10 + y);
            }
            if ((y - 1 <= 5 && y - 1 >= 3) && (buttons[x , y-1].Tag == null || (buttons[x, y-1].Tag as QiZi).Player != this.Player))
            {
                int z = Game.ChangeDirection(this.Player, x);
                canPut.Add(z * 10 + y-1);
            }
            if ((y + 1 <= 5 && y + 1 >= 3) && (buttons[x , y+1].Tag == null || (buttons[x , y+1].Tag as QiZi).Player != this.Player))
            {
                int z = Game.ChangeDirection(this.Player, x);
                canPut.Add(z * 10 + y + 1);
            }
            int x1 = x;
            while (true)
            {
                x1++;
                if (x1 > 9)
                    break;
                if (buttons[x1, y].Tag == null)
                {
                    continue;
                }
                else if ((buttons[x1, y].Tag as QiZi).name != "帅")
                {
                    break;
                }
                else
                {
                    int z = Game.ChangeDirection(this.Player, x1);
                    canPut.Add(z * 10 + y);
                    break;
                }
            }
        }
    }
}
